package filter;

import javax.servlet.*;
import java.io.IOException;

/**
 * 04-Filter生命周期
 */
public class Demo02Filter implements Filter {


    public Demo02Filter() {
        System.out.println("Demo02Filter实例化");
    }

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("Demo02Filter初始化");

    }

    @Override
    public void destroy() {
        System.out.println("Demo02Filter销毁");
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        System.out.println("Demo02Filter 过滤");
        chain.doFilter(request, response);//相当于执行Demo01Servlet
        System.out.println("Demo02Filter 放行");

    }
}
